import { http } from '@/utils'

// 获取文章列表
export function getArticles (params) {
  return http({
    url: 'mp/articles',
    params
  })
}

// 删除文章
export function delArticle (id) {
  return http({
    url: 'mp/articles/' + id,
    method: 'delete'
  })
}

// 发表文章
export function addArticle (data, draft) {
  return http({
    url: 'mp/articles',
    method: 'post',
    data,
    params: {
      draft
    }
  })
}

// 获取文章详情
export function getArticleInfo (id) {
  return http({
    url: 'mp/articles/' + id
  })
}

// 编辑文章
export function editArticle (data, draft) {
  return http({
    url: 'mp/articles/' + data.id,
    method: 'put',
    data,
    params: {
      draft
    }
  })
}
